//---1
new Promise(function(resolve, reject) {
    setTimeout(function() {
        resolve(1);
    }, 1000);
}).then(alert, alert);

new MyPromise(function(resolve, reject) {
    setTimeout(function() {
        resolve(1);
    }, 1000);
}).then(alert, alert);


//---2
new Promise(function(resolve, reject) {
    setTimeout(function() {
        resolve(1);
    }, 1000);
}).then(alert, alert).then(alert, alert);

new MyPromise(function(resolve, reject) {
    setTimeout(function() {
        resolve(1);
    }, 1000);
}).then(alert, alert).then(alert, alert);

//---3
new Promise(function(resolve, reject) {
    setTimeout(function() {
        reject(404);
    }, 1000);
}).then(alert, alert).then(alert, alert);

new MyPromise(function(resolve, reject) {
    setTimeout(function() {
        reject(404);
    }, 1000);
}).then(alert, alert).then(alert, alert);

//---4
new Promise(function(resolve, reject) {
    setTimeout(function() {
        reject(new Error('x'));
        resolve(2);
    }, 1000);
}).then(alert, function(error) {
    console.log(error);
    return 1;
}).then(alert, alert);

new MyPromise(function(resolve, reject) {
    setTimeout(function() {
        reject(new Error('x'));
        resolve(2);
    }, 1000);
}).then(alert, function(error) {
    console.log(error);
    return 1;
}).then(alert, alert);